package org.zuel.innovative.power;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class PowerConfig implements WebMvcConfigurer {
    @Autowired
    private  LoginTicketInterceptor loginTicketInterceptor;

    @Autowired
    private PowInterceptor powInterceptor;



    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(loginTicketInterceptor)
                .excludePathPatterns("/css/**", "/js/**", "swagger-ui.html","/img/**", "/editor-md/**", "/editor-md-upload/**");


        registry.addInterceptor(powInterceptor)
                .excludePathPatterns("/css/**", "/js/**", "swagger-ui.html","/img/**", "/editor-md/**", "/editor-md-upload/**");


    }

    @Bean("contro")
    Map<String, Integer> contro(){
        Map<String, Integer> controller=new HashMap<>();
        //添加接口权限
        controller.put("/login/logout", 1);
        controller.put("/discuss/add", 1);
        controller.put("/discuss/delete", 1);
        controller.put("/discuss/top", 2);
        controller.put("/discuss/update", 1);
        controller.put("/discuss/wonderful", 1);
        controller.put("/comment/add", 1);
        controller.put("/message", 1);
        return controller;
    }
}
